home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Tools (InfoMagic)
/
Internet Tools.iso
/
news
/
moderating
/
autoreply.shar.Z
/
autoreply.shar
Wrap
Internet Message Format
|
1994-05-06
|
8KB
From tale@uunet.uu.net Thu Oct 14 10:34:28 1993
Received: from uunet.uu.net by sparky.Sterling.COM (5.65c/IDA-1.4.4)
id AA09562; Thu, 14 Oct 1993 10:34:26 -0500
Return-Path: <tale@uunet.uu.net>
Received: by rodan.UU.NET (5.61/UUNET-mail-drop)
id AA22594; Thu, 14 Oct 93 11:24:36 -0400
Received: by rodan.UU.NET (5.61/UUNET-mail-drop)
id AA22584; Thu, 14 Oct 93 11:24:33 -0400
Date: Thu, 14 Oct 93 11:24:33 -0400
From: tale@uunet.uu.net (David C Lawrence)
Message-Id: <9310141524.AA22584@rodan.UU.NET>
To: moderators@uunet.uu.net
Subject: Re: Procmail question and a little comment
In-Reply-To: <9310141312.AA20784@top.magnus.acs.ohio-state.edu>
References: <9310141312.AA20784@top.magnus.acs.ohio-state.edu>
Status: OR
Coyt D Watters writes:
> First of all, can anyone on the Moderator's List point me to a decent
> instruction manual for .procmail? The man pages don't do it for me
> (I'm no Unix wiz).
I don't know of one, but you can try asking the author:
berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
There is also a mailing list: procmail-request@informatik.rwth-aachen.de
> All I really want to do is send a canned reply back to the send that hir
> post to rec.games.frp.announce has been recieved and will be reviewed.
I sent something like this to the moderator's list previously. I'll
append a version of it. It also uses perl.
> I'm already using it to do sorting and filing (had to add a Moderators
> mailbox this morning, 53 message in 24h, sheesh).
Oh, this makes it a little more tricky, but not much. The procmailrc
in the example delivers any mail that doesn't get an autoreply to the
spool folder, and then runs the rest through a filter to fix the
"headers in the body" problem, then tries the auto-replies. Depending
on the nature of your filing, you can either just hang it off the
auto-reply catches or might have to restructure how you handle
ignoring some addresses for the reply.
#! /bin/sh
# This is a shell archive. Remove anything before this line, then feed it
# into a shell via "sh file" or similar. To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# Contents: arep headstrip procmailrc
# Wrapped by tale@rodan on Thu Oct 14 11:21:18 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo If this archive is complete, you will see the following message:
echo ' "shar: End of archive."'
if test -f 'arep' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'arep'\"
else
echo shar: Extracting \"'arep'\" \(2729 characters\)
sed "s/^X//" >'arep' <<'END_OF_FILE'
X#!/bin/perl
X#
X# based on a shell script by scott hazen mueller
X# tale, july 1993
X#
X# Auto-reply to an email message. $1 is the name of a reply form
X# letter file to use. Input is an email message to search for the
X# reply address. Try to avoid sending the same reply to the same
X# recipient twice in a one-week interval, just like vacation
X
X#customise:
X$arep = "/home/tale/.arep";
X$interval = 60 * 60 * 24 * 7; # seconds between auto-replies
X$msgdir = "/home/tale/forms/auto-replies";
X$sendmail = "/usr/lib/sendmail";
X$from = 'David C Lawrence <tale@ten.uu.net>';
X#end
X
Xdie "usage: $0 reply-file" if $#ARGV != 0;
X
X$cutoff = time - $interval;
X
Xdbmopen(%arep, $arep, 0666) || die "$0: dbmopen $arep: $!\n";
X
X$* = 1; # let ^ and $ work with newlines embedded in input.
X
X$/ = ""; # read until empty line mode
X$_ = <STDIN>; # get the whole header
Xs/\n\s+/ /g; # rejoin continued lines
X
X# save the subject; we will trounce on $_ in a moment.
X($subject) = /^Subject: (.*)/i;
X
X# try to get reply address. same basic heuristics as gene/scott's "reply"
X# prog, but doesn't clean it up with fixfrom like the shell script did.
X/^Reply-To: (.+)/i || /^From: (.+)/i || /^Return-Path: (.+)/i || /^From (\S+)/i;
X
X# try to ditch an obvious comment. it could possibly have a <...> in it.
X# not rfc 822 strict with matching or quoted parens.
X($_ = $1) =~ s/\(.*\)//;
X
X# takes either the "Comment <address>" or "address" (parenthetical
X# comment was just stripped above) to get the essential address.
X# this will fail for some various perversities of RFC 822, like quoted
X# spaces in local address parts. rfc 822 syntax is the work of the
X# devil, not a programmer.
X(($reply) = /<(.+)>/) || (($reply) = /^\s*(\S+)/);
X
X# do we need to send a reply?
Xexit 0 if $arep{$reply} && $arep{$reply} > $cutoff;
X
X# Send the reply.
X# First, touch up the subject
X$subject = 'Re: your mail' if !$subject;
X$subject =~ s/^/Re: / if $subject !~ /^\s*Re:/i;
X$subject = '[auto-reply] ' . $subject;
X
X# Next, get the message to send.
Xopen(MSG, "<$msgdir/$ARGV[0]") || die "$0: open $msgdir/$ARGV[0]: $!\n";
Xundef $/; # slurp the whole thing in
Xchop($msg = <MSG>);
X
Xopen(MAIL, "| $sendmail $reply") || die "$0: calling sendmail: $!\n";
X
Xprint MAIL <<EOF;
XFrom: $from
XTo: $reply
XSubject: $subject
X
XNote of the week: I have been really hit with work for UUNET, so my
Xpersonal mailbox has filled a bit. Expect delays.
X
XThis is an automatically generated reply to a message from you which
Xlanded in my mailbox. Auto-replies of all forms from me will only be
Xsent once per week to any given address. Use a Return-Receipt-To
Xheader if you want confirmation of specific mail messages you send to me.
X
X$msg
XEOF
X
X$arep{$reply} = time;
Xexit 0;
END_OF_FILE
if test 2729 -ne `wc -c <'arep'`; then
echo shar: \"'arep'\" unpacked with wrong size!
fi
chmod +x 'arep'
# end of 'arep'
fi
if test -f 'headstrip' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'headstrip'\"
else
echo shar: Extracting \"'headstrip'\" \(342 characters\)
sed "s/^X//" >'headstrip' <<'END_OF_FILE'
X#! /bin/sed -f
X# the script is for use with a procmail recipe that has determined
X# that the real news headers for a submission to a moderated group
X# appear to lead the body of the message. it gets them into the
X# mail headers without loss of information.
X
Xs/^From: /X-Mail-Submission-From: /
X/^$/ {
X N;s/^.//
X : ptoeof
X n
X b ptoeof
X}
END_OF_FILE
if test 342 -ne `wc -c <'headstrip'`; then
echo shar: \"'headstrip'\" unpacked with wrong size!
fi
chmod +x 'headstrip'
# end of 'headstrip'
fi
if test -f 'procmailrc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'procmailrc'\"
else
echo shar: Extracting \"'procmailrc'\" \(1139 characters\)
sed "s/^X//" >'procmailrc' <<'END_OF_FILE'
X# use with .forward file:
X# "|IFS=' ';exec /usr/local/bin/procmail -t #tale"
X
XCOMSAT=no
XBIN=$HOME/bin
X
X# conditions for which there should be never be an auto-reply.
X# it is only here to get procmail to deliver the mail then quit
X# out of the procmailrc processing.
X# all local addresses are fully qualified when procmail is called.
X::
X*^((Resent-)?From:.*(uu\.net|moraes@deshaw\.com|D\.W\.Wright@bnr\.co\.uk|\
Xurlichs@smurf\.sub\.org)|Precedence: (bulk|junk))
X$ORGMAIL
X
X# try to identify moderated posts with headers in the start of the body.
X# the ^^ anchors it at the start of the body, the ($)* skips leading empty
X# lines, the (.+$)* limits the search for the header up to the next empty
X# line.
X:Bfw
X* ^^($)*(.+$)*Newsgroups: .
X* ^^($)*(.+$)*Path: .
X* ^^($)*(.+$)*From: .
X* ^^($)*(.+$)*Date: .
X* ^^($)*(.+$)*Subject: .
X* ^^($)*(.+$)*Message-ID: .
X| $BIN/headstrip
X
X:c:arep
X*^TO.*news?groups
X| $BIN/arep news.announce.newgroups
X
X:c:arep
X*^TO.*news-lists
X| $BIN/arep news.lists
X
X:c:arep
X*^TO.*group-advice
X| $BIN/arep group-advice
X
X:c:arep
X*^TO.*moderators-request
X| $BIN/arep moderators-request
X
X:c:arep
X*^TO.*tale
X| $BIN/arep tale
END_OF_FILE
if test 1139 -ne `wc -c <'procmailrc'`; then
echo shar: \"'procmailrc'\" unpacked with wrong size!
fi
# end of 'procmailrc'
fi
echo shar: End of archive.
exit 0